package com.hxd.tabactivityfragment.ui.fragment.MineOfFragment

import com.hxd.tabactivityfragment.R
import com.hxd.tabactivityfragment.bean.IMPDataInfo.IMPSucharDataInfoBean
import com.hxd.tabactivityfragment.bean.IMPDataInfo.MiklProduct.Desc
import com.hxd.tabactivityfragment.bean.IMPDataInfo.MiklProduct.InspectInfoDesc
import com.hxd.tabactivityfragment.common.MyFragment
import com.hxd.tabactivityfragment.util.BannerDataUtil
import com.hxd.tabactivityfragment.util.GsonToBean
import com.vondear.rxtool.RxSPTool
import kotlinx.android.synthetic.main.fragment_find_distributor_info.*

/**
 *  项目名：    FoodOrigins
 *  包名：      com.hxd.tabactivityfragment.ui.fragment
 *  文件名:     DistributorInfoFragment
 *  创建者:     HXD
 *  创建时间:   2019/3/24 15:43
 *  描述:       销售商销售商数据界面
 */

class DistributorInfoFragment:MyFragment() {
    override fun getLayoutId(): Int {
        return R.layout.fragment_find_distributor_info
    }

    override fun getTitleBarId(): Int {
        return 0
    }

    //设置单例静态方法
    companion object {
        fun newInstance(): DistributorInfoFragment {
            return DistributorInfoFragment()
        }
    }

    override fun initView() {
        //配置轮播图
        sib_simple_usage_di.setSource(BannerDataUtil.getDatas())
            .setOnItemClickL { position -> myToast("position--->$position") }
            .setIsOnePageLoop(false).startScroll()
    }

    override fun initData() {
        var searchData = RxSPTool.getString(context, "IMPSucharDataInfoBean")
        var bean = GsonToBean.JsonToBean<IMPSucharDataInfoBean>(searchData)
        var productInfo = GsonToBean.JsonToBean<Desc>(bean.data.desc)
        var productTest = GsonToBean.JsonToBean<InspectInfoDesc>(bean.data.inspect_info.desc)

        //初始化产品信息
        tv_title.text = productInfo.title
        tv_ingredient.text = productInfo.ingredient
        tv_packaging.text = productInfo.packaging
        tv_license.text = productInfo.license
        tv_expiration.text = productInfo.expiration
        tv_sales.text = productInfo.sales
        tv_suitable.text = productInfo.suitable
        tv_desc.text = productInfo.desc

        //初始化产品检测
        tv_detection_mechanism.text = productTest.detection_mechanism
        tv_report_number.text = productTest.report_number
        tv_brand.text = productTest.brand
        tv_specification.text = productTest.specification
        tv_inspection_type.text = productTest.inspection_type
        tv_contact.text = productTest.contact
        tv_inspec_name.text = productTest.inspec_name
        tv_sample_status.text = productTest.sample_status
        tv_sealed_status.text = productTest.sealed_status
        tv_according.text = productTest.according
        tv_result.text = productTest.result
    }
}